
// 1 sequence for this 
// .. 
CHnting = function() {

	this.class_this = 1;
	this.objName = 'CHnting : ';
	//hnt = this;
	// define stage 
	this.action_stage = new Array(6);
	
	this.prevDA_index	= 0;

	// define sol num 
	this.solnum = {} ;
	this.solnum.sp = 2;
	this.solnum.lanu = 8;
	this.solnum.ov = 15;
	this.solnum.k = 17;

	// cit 
	this.maxcit = 5;
	this.cit = new Array(this.maxcit);
};

CHnting.DA1ATT_DONE = 0;
CHnting.INFORM_ATTNUM = 1;

CHnting.DA_INVALID = 9;
CHnting.SOL_INVALID = 10;

CHnting.FAIL_ATT_WCOST = 11;
CHnting.FAIL_ATT = 12;
CHnting.NO_HERO = 13;
CHnting.ATT_MAX = 14;
CHnting.LESS_CONTROLNUM = 15;
CHnting.LESS_SOLS = 16;
CHnting.FAIL_GETFAVS = 17;
CHnting.RESEARCH_INVALID = 18;


CHnting.prototype = {



	setTgt: function(att_param) {
		// att param :  x, y, tr: { s : n , b: n , o : n }, success_cb , error_cb 
		// store values
		this.tgt = att_param.da;
		this.citnum = att_param.citnum; 
		this.h = att_param.h;
		debug.log(this, 'Done Set TA ', att_param);
		
	},
	
		
		
	doAttc: function () {
	
		debug.log(this, retName(this));
		// clear  vars  
		this.next_action_idx = 0;		// reset index
		this.attinfo = {}; 			// clear 
		this.trs = {};
		
		this.goNextAction();
		},





	goNextAction: function() {
				// go next 
		this.next_action_idx += 1; 
			
		// done complete!
		if ( this.next_action_idx >= this.action_stage.length ) {
			debug.log(this, retName(this), ' Done Hnt Action!! ');
			
			this.next_action_idx = 0;
			em.cbs.hntingerr.fire(CHnting.DA1ATT_DONE, this.attinfo);
			
			return;
		}
		
		
		debug.log(this, retName(this), this.action_stage[this.next_action_idx].cmd  +   '  start!! '
			,this.action_stage[this.next_action_idx].doaction
			 ,this);

		
		// !!!  this. 占쏙옙占쎈챷�㏆옙占썲첎�밴퍥 ..  docation 占쎈뜆��this 占쏙옙獄쏄퀣肉댐옙占�揶쏆빘猿쒏에占썼퉪占쎈뻿..  占쎄퀡�わ옙占�this �쒙옙 hnt mgr 嚥∽옙 癰귨옙瑗랃옙�곴퐣 占쎈챷��.

		var outer = this;

		outer.action_stage[outer.next_action_idx].doaction.call(outer);
		
				
	},


	
	doTest : function() {
			this.goNextAction();
	},
	
	
	doTest2nd: function() {
			this.goNextAction();
	},
		


	// DA Array �쒙옙獄쏆룇��   this 揶쏉옙caller...  window 揶쏆빘猿�.揶쏉옙占쏙옙  
	checkWmap: function(da_arr) {
		
		this.da_arr = da_arr;
		debug.log(this, /*retName(this),*/ ' start ' , da_arr);

		
		var da_valid = false;
		
		// check cur co odi  is valid 
		var outer = this;
		$.each( this.da_arr,  function (i, item) {
			// [222,252,4,[4]],
			console.log(item);
			if ( item[0] == outer.tgt.x && item[1] == outer.tgt.y ) {
				// found !! co odi, : check start, & quater
				debug.log(outer,  ' FOUND  : this is cur DA :  ' , item);
				
				// change... mode... all condition is checked by hntmgr ... !!! 
//				if ( CDA.wantStar(item[2]) && CDA.goodQuater(item[3][0]) ) {
				if ( 1 ) {
					// check ok. valid !! 
					debug.log("x: " + item[0] + " Y : " + item[1] + " start : " + item[2] + "quater: "+ item[3]);
					da_valid = true;
				}
			}
		});
		
		
		if ( da_valid == false ) {
			// abort actions.. noty to caller 
			debug.log(this,  ' NOT FOUND  : Set DA :  ', this.tgt);
			em.cbs.hntingerr.fire(CHnting.DA_INVALID);
			// abort actions 	 nothing to do   
			
		} else  {
		// go next action
			// this.goNextAction();
			setTimeout( function() { outer.goNextAction(); } ,CUtil.RandTime(2500));
		}
	},
	
	doWMap: function(  ) {
		 // make world param  
		 var outer = this;
		debug.log(this, retName(this), ' start ');	
		var param = { x: this.tgt.x , y: this.tgt.y , cb : function (data) { 
					outer.checkWmap.call(outer, data); }};
		em.ahelper.worldMap(param);
	},
		
	


	checkSolEdu: function(soldata) {
		// this.soldata = soldata;
		debug.log("got soldata  in hunt " ,  soldata  );
		/*
		{"code":0,
"ret":
{"soldiers":
[[1,0,1],[2,121,1],[3,0,1],[4,0,1],[5,0,1],[6,0,1],[7,0,1],[8,1528,1],[9,0,1],[10,12,1],[11,0,1],[12,0,1],[13,0,1],[14,0,1],
[15,2077,1],[16,0,1],[17,2699,1],[18,1,1]],
"space":6562,"head":8356,"def":1,"next":[0,0],"f":-38261}})
				*/
				
		// update cstl with sols  : before err cb fire 
		if ( soldata.ret.soldiers) {
			em.cbs.updatesols.fire(soldata.ret.soldiers);		// array
		}
			
		this.sols = soldata.ret.soldiers;

		var outer =this;
		setTimeout( function() { outer.goNextAction(); } ,CUtil.RandTime(1000));
		// this.goNextAction();
	},
		
		
	
	doSolEdu: function(  ) {
		//&city=3070
		var outer = this;		
		var param = { citnum: this.citnum,  cb : function (data) { 
				outer.checkSolEdu.call(outer, data); }
		};

		em.ahelper.solEdu(param);
	},


	
	/*
		{"id":9176,"gid":210,"p":44,"i":8,"c1":17,"f":34,"g":12,"c2":613,"fy":0,"s":0,"e":10,"w":0,"tw":30,"tl":79,
	"ex":59758,"te":257100,"np":0,"ni":0,"nc1":0,"nc2":0,"ns":0,"ncd":0,"pr":36000},
	*/
	checkConscribe: function(hero_arr) {
		// data = hero 
		if ( hero_arr.length == 0) {
			// no Hero!! 
			debug_log( "no HHHHHero in here  ");
			// stop & notify error 
			// TODO :  이걸, cb  event 처리..
			em.cbs.hntingerr.fire(CHnting.NO_HERO);
			return;
			
		} else {
			
			// hro list 구성.  recv data is array . 
			em.cbs.warableHpdate.fire(hero_arr);
			
			// check bestH is exist  ..
			var self = this;
			var matchedH = hero_arr.filter( function(el){ return el.gid == self.h.gid})[0];
			if ( ! matchedH) {
				// no same hero !!!  something Wrong!!!
				debug.log(this,3, 'no same hero !!!  something Wrong!!!');
				em.cbs.hntingerr.fire(CHnting.NO_HERO);
				return;
			} 		

			this.h.gid = matchedH.gid;
			var max_control = matchedH.c2;
			var da =  this.tgt;
			this.trs.o = CUtil.calcNeedO( matchedH , da);
			
			if ( max_control < this.trs.o ){
				debug.log(this, 3, ' something Wrong!!! ERR: H-control ' +  max_control + ' is less ( < ) ' + ' req sol : ' +  this.trs.o  );
				// error ... less contorl number .. 
				em.cbs.hntingerr.fire(CHnting.LESS_CONTROLNUM);
				return;
			}
	
	
			// check cur number of castle soldi...
					
		var s = this.sols.filter( function(el) { return el[0] == CDB.SOLS.SPY})[0];
		var ber = this.sols.filter( function(el) { return el[0] == CDB.SOLS.BER})[0];
		var over = this.sols.filter( function(el) { return el[0] == CDB.SOLS.OVER})[0];
		
		debug.log(this, 'Sols , s: ' ,  s ,' b :' ,ber , ' o: ' , over);
		var ns = s ? s[1]: 0;
		var nb = ber ? ber[1]: 0;
		var no = over ? over[1]: 0;

		// check sufficient o 
		if ( no < this.trs.o ) {
			// try with berserk ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
			if ( CDB.getCurUserOptions().hntSols == 'O&B' ) {
					debug.log(this, 1, 'try with berserk: ~~~~~~~~~~~~~~~~' );
	
					this.trs.b = CUtil.calcMoreB(matchedH, da, no);
					if ( nb < this.trs.b ) {	// skip 
						em.cbs.hntingerr.fire(CHnting.SOL_INVALID);
						return;
					}
				// go hnt!! with o & b 
				this.trs.o = no;
				// this.trs.b
				
				// add hunt for speed  : 100
				var hnt = this.sols.filter( function(el) { return el[0] == CDB.SOLS.HNT})[0];
				var nh = hnt ? hnt[1]: 0;
				var possibleHnt = max_control - no - this.trs.b ;
				nh = nh > possibleHnt ? possibleHnt : nh;
				 
				this.trs.h = nh > 100 ? 100: nh;
				
			} else {		// 
				em.cbs.hntingerr.fire(CHnting.SOL_INVALID);
				return;
			}
		}
		
		
		debug.log(this, ' Sending trs  o: ' , this.trs.o , ' b :', (this.trs.b ? this.trs.b: 0 ) ,' h: ' , this.trs.h);
			// set timeout for emul hand this
			// setTimeout( "this.goNextAction()" ,CUtil.RandTime(1500));
			var outer = this;
			setTimeout( function() { outer.goNextAction(); } ,CUtil.RandTime(1000));			
			// this.goNextAction();
		}
	},
	
	
	
	doConscribe: function(  ) {
		//&city=14281&action=gen_list&extra=1
		var outer = this;
		var param = { citnum: this.citnum, extra: 1, cb : function (data) { 
				outer.checkConscribe.call(outer, data); }
		};
		em.ahelper.conscribe(param);
	},







	checkArmament_set_ta: function(data) {
		 // {"code":0,"ret":0} 
		 debug_log( " got arm set ta  ")
		this.valid_ta  = data.ret;
		
		//  notify to hntmgr att count 
		em.cbs.hntingerr.fire(CHnting.INFORM_ATTNUM, data.ret);
		
		if ( this.valid_ta >= GetMaxAtt()) {	// att count 
			// invalid : target   
			debug_log( " Armament : max att count !!  TA !!!  " + this.valid_ta )
			
			em.cbs.hntingerr.fire(CHnting.ATT_MAX);
			
		} else {
			var outer =this;
			
			setTimeout( function() { outer.goNextAction(); } ,CUtil.RandTime(1000));
			// this.goNextAction();
		}	
	},
	
	doArmament_set_ta: function() {
// sel ta
//&city=14281&act=anum&x=205&y=248
		var outer = this;
		var param = { citnum: this.citnum,  x: this.tgt.x, y: this.tgt.y, cb : function (data) { 
				outer.checkArmament_set_ta.call(outer, data); } };
		em.ahelper.armament_action_set_ta(param);
	},

//GET /game/armament_action_do_api.php?jsonpcallback=jQuery17045742537174373865_1322329422217&key=83f3cd5da55f9c02536501a0a7011f52&city=3070&action=do_war&attack_type=7&gen=71&area=185&area_x=49&soldier_num15=244&_l=en&_p=EW-DROID&carry=263520&cost_food=43920&cost_wood=0&cost_iron=0&cost_gold=0&distance=2400&travel_sec=0&_=1322329443822 HTTP/1.1


	// cost �쒙옙占쏙옙�ｏ옙占�
	checkArmament_at: function(data) {
		 // ({"code":0,"ret":{"carry":6000,"cost_food":6000,"cost_wood":0,"cost_iron":0,"cost_gold":0,"distance":2400,"travel_sec":360}})
		this.cost  = data.ret;
		if (  data.code != 0 ) {
			// invalid : target   
			debug_log( " invalid att ret code  ")
			em.cbs.hntingerr.fire(CHnting.FAIL_ATT);
		} else {
			var outer =this;
			
			this.carry = data.ret.carry;
			this.traveltime = new Date((new Date()).getTime() + data.ret.travel_sec * 1000 );	// for pvp server 		
			
			setTimeout( function() { outer.goNextAction(); } ,CUtil.RandTime(500));
				// this.goNextAction();
	
		}

	},
	
	doArmament_at: function(  ) {
		 this.ATTC = 7; // att type 
		// att 
		//&city=14281&action=do_war&attack_type=7&gen=210&area=205&area_x=248&soldier_num2=100

		var outer = this;		
		var param = { citnum: this.citnum,
			atttype: this.ATTC , // 7  , 3 : scan 
			genid : this.h.gid,  	// recv in conscribe 
			 troops : this.trs,	// set o num : 占쎈벡�ㅿ옙占�sol_edu 占쎈Ŋ苑�占쎌꼹六억옙�됱벉.   
			x: this.tgt.x, y: this.tgt.y, 
			cb : function (data) { 
				outer.checkArmament_at.call(outer, data); } 
				 };
			
		em.ahelper.armament_action_att(param);
	},



	checkArmament_at_cost: function(data) {
		 // ({"code":0,"ret":{"cd":[{"id":3235418,"cdtype":4,"target":7,"owner":210,"secs":360,"ret":0,"ext":"205\/248"}] }    }) 
		this.hnt_result   = data.ret.cd;
		if (  data.code != 0 ) {
			// invalid : target   
			debug_log( " invalid att w cost  ");
			em.cbs.hntingerr.fire(CHnting.FAIL_ATT_WCOST);
		} else {
			
			this.returntime = new Date((new Date()).getTime() + this.hnt_result[0].secs*2 * 1000);		// round trip * 2
			
			debug.log(this, 11111, 'Done! : sec : ' + this.hnt_result[0].secs  
						+ ' end: ' + this.returntime.getMinutes() + ':' + this.returntime.getSeconds() );
						
			debug.log(this, 55555, { sec:  this.hnt_result[0].secs ,
											   coodi: this.hnt_result[0].ext ,    
											   returntime: this.returntime} );
			
			// notify hntinfo 			
			this.attinfo = { 
				h: this.h, 
				trs: this.trs,
				cost:  this.cost,
				// sec: this.hnt_result[0].secs, 
				endtime: this.returntime,
				carry: 	this.carry,
				traveltime: this.traveltime,
				};
			
			// update cd result ( hnt result)
			$.extend( this.attinfo, data.ret.cd[0]);
			
			var outer =this;
			setTimeout( function() { outer.goNextAction(); } ,CUtil.RandTime(500));
			// setTimeout( "this.goNextAction()" , CUtil.RandTime(1000));
			// this.goNextAction();
		}	
	},
	
	
	// arament_at 占쎈Ŋ苑�獄쏆룇占�cost �쒙옙 �븐늿肉�餓ο옙�� 
	doArmament_att_wcost : function() {
		 this.ATTC = 7; // att type 
// att cost 
//&city=14281&action=war_task&attack_type=7&gen=210&area=205&area_x=248&soldier_num2=100&_l=en&carry=6000.... 
		var outer = this;
		var param = { citnum: this.citnum,
			atttype: this.ATTC , // 7  , 3 : scan 
			genid : this.h.gid,  	// recv in conscribe 
			 troops : this.trs,	// set o num : 占쎈벡�ㅿ옙占�sol_edu 占쎈Ŋ苑�占쎌꼹六억옙�됱벉.   
			x: this.tgt.x, y: this.tgt.y,
			
			cost: this.cost,		// cost ..   
			cb :  function (data) { 
				outer.checkArmament_at_cost.call(outer, data); }
				 };
			
			em.ahelper.armament_action_att_wcost(param);
	},


/*
	GET /game/api_fav.php?
	jsonpcallback=jsonp1322284134980&_=1322284229576&key=83f3cd5da55f9c02536501a0a7011f52
	&act=getfavnpc
	&cat=2
	&_l=en&_p=EW-DROID HTTP/1.1


jsonp1322284134980({"code":0,"ret":
{"favs":[
	[31205,149,49,1,3],
	[43720,183,58,1,3],
	[43826,147,63,1,3],
	[43898,155,67,1,3],
	[47256,72,22,1,3],
	[47257,35,27,1,3],
	[47268,81,15,1,3],
	[47271,192,17,1,3],
	[47275,179,19,1,3],[47276,148,16,1,3],[47277,280,8,1,3],[47282,78,12,1,3],[47302,84,12,1,0],[47402,258,38,1,0],[47413,278,34,1,0],[47417,86,29,1,0],[47418,207,29,1,0],[47421,143,29,1,0],[47423,146,32,1,0],[47424,6,31,1,0],[47427,274,21,1,0],[47431,216,26,1,0],[47432,207,22,1,0],[47434,197,24,1,0],[47435,137,24,1,0],[47439,189,27,1,0],[47467,65,47,1,0],[47470,215,48,1,0],[47471,80,51,1,0],[47478,223,62,1,0],[47480,205,56,1,0],[47481,195,59,1,0],[47482,12,57,1,0],[47484,247,58,1,0],[47488,85,68,1,0],[47490,266,50,1,0],[47491,227,54,1,0],[47556,235,89,1,0],[47559,138,87,1,0],[47561,230,87,1,0],[47563,135,84,1,0],[47565,217,84,1,0],[47569,43,90,1,0],[47570,11,96,1,0],[47571,277,84,1,0],[47573,210,90,1,0],[47574,7,86,1,0],[47575,6,86,1,0],[47576,4,82,1,0],[47577,7,77,1,0],[47578,77,81,1,0],[47579,129,83,1,0],[47581,3,80,1,0],[47584,204,77,1,0],[47585,189,81,1,0],[47586,179,80,1,0],[47587,83,76,1,0],[47588,234,74,1,0],[47589,237,70,1,0],[47590,38,75,1,0],[47591,15,73,1,0],[47592,277,67,1,0],[47593,95,68,1,0],[47594,139,65,1,0],[47596,187,64,1,0],[47737,164,127,1,0],[47738,241,123,1,0],[47740,163,121,1,0],[47741,236,114,1,0],[47742,68,115,1,0],[47744,85,117,1,0],[47745,82,112,1,0],[47746,132,135,1,0],[47747,224,135,1,0],[47748,152,115,1,0],[47753,13,115,1,0],[47759,215,158,1,0],[47760,268,106,1,0],[47761,52,107,1,0],[47762,233,108,1,0],[47763,218,105,1,0],[47764,69,110,1,0],[47765,23,111,1,0],[47769,148,111,1,0],[47778,259,104,1,0],[47779,259,103,1,0],[47782,63,98,1,0],[47787,245,98,1,0],[47793,218,99,1,0],[47794,163,101,1,0],[47795,70,95,1,0],[47796,219,92,1,0],[47802,35,91,1,0],[47806,207,96,1,0],[51319,124,119,2,0],[51320,231,125,2,0],[51321,155,125,2,0],[51324,221,112,2,0],[51325,175,110,2,0],[51326,124,77,2,0],[51327,126,69,2,0],[51328,280,80,2,0],[51329,221,73,2,0],[51330,265,77,2,0],[51331,267,76,2,0],[79421,34,97,1,0],[79696,36,143,1,0],[79701,111,141,1,0],[79702,21,140,1,0],[79703,255,132,1,0],[79704,250,133,1,0],[79711,90,135,1,0],[79718,30,132,1,0],[79719,90,128,1,0],[79720,104,127,1,0],[79721,170,126,1,0],[79730,37,128,1,0],[79733,235,122,1,0],[79898,71,163,1,0],[79899,59,161,1,0],[79900,85,162,1,0],[79902,28,158,1,0],[79903,23,159,1,0],[79904,21,158,1,0],[79905,13,151,1,0],[79907,83,164,6,0],[79908,120,155,1,0],[79909,62,151,1,0],[79910,57,157,1,0],[79911,53,151,1,0],[79912,278,146,1,0],[79913,260,148,1,0],[79914,239,150,1,0],[79915,51,149,1,0],[79917,98,145,1,0],[79918,96,148,1,0],[79919,83,148,1,0],[79920,196,145,1,0],[79921,167,144,1,0],[79922,237,139,1,0],[80766,181,51,5,0],[80767,184,53,5,0],[80768,181,43,5,0],[80769,180,43,5,0],[80770,194,50,1,0],[80771,175,51,1,0],[80783,201,42,1,0],[80786,203,53,1,0],[80787,197,34,1,0],[80788,164,55,1,0],[80789,182,28,1,0],[80790,168,71,1,0],[80791,167,40,1,0],[80793,212,50,1,0],[80795,171,79,1,0],[80796,161,83,1,0],[80797,160,40,1,0],[80830,166,13,1,0],[80832,156,10,1,0],[80835,147,73,1,0],[80837,190,90,1,0],[80839,221,42,1,0],[80840,223,38,1,0],[80842,222,34,1,0],[80843,220,31,1,0],[80846,173,20,1,0],[80847,165,18,1,0],[80848,157,19,1,0],[81280,153,98,1,0],[81705,230,4,1,0],[81707,220,95,1,0],[81708,186,95,1,0],[81709,209,94,1,0],[81710,229,38,1,0],[96214,222,49,4,0],[96215,222,44,4,0],[96216,212,280,1,0],[96217,236,117,1,0],[96218,4,106,1,0],[96219,253,111,1,0],[96220,124,106,1,0],[96221,110,95,1,0],[96223,98,87,1,0],[96224,4,31,1,0],[96225,269,63,1,0],[96226,277,102,1,0],[96227,270,82,1,0],[96228,156,104,1,0],[96229,168,104,1,0],[96231,221,47,4,0],[96233,225,39,4,0],[96234,272,1,1,0],[96235,214,273,1,0],[96236,219,275,1,0],[96237,176,277,1,0],[96238,253,276,1,0],[96239,268,13,1,0],[96240,205,275,1,0],[96241,265,18,1,0],[96242,101,7,1,0],[96243,249,117,1,0],[96246,102,12,1,0],[96247,114,9,1,0],[96248,237,5,1,0],[96249,151,4,1,0],[96250,229,279,1,0],[96251,136,2,1,0],[96252,194,52,4,0],[96253,202,60,4,0],[96254,259,115,1,0],[96266,128,113,1,0],[96268,95,116,1,0],[98938,15,5,1,0],[98939,21,22,1,0],[98940,17,58,1,0],[98941,19,100,1,0],[98942,28,103,1,0],[98943,23,73,1,0],[98944,18,113,1,0],[98945,26,42,1,0],[98947,28,38,1,0],[98950,28,274,1,0],[98952,34,72,1,0],[98954,95,46,1,0],[98955,96,65,1,0],[98957,97,66,1,0],[98959,89,32,1,0],[98960,91,112,1,0],[98961,90,23,1,0],[98962,80,277,1,0],[98963,82,29,1,0],[98964,82,28,1,0],[98965,78,40,1,0],[98966,77,61,1,0],[98968,81,129,1,0],[98969,75,87,1,0],[98970,75,86,4,0],[98971,76,81,1,0],[98972,76,116,1,0],[98973,71,110,1,0],[98974,74,25,1,0],[98976,65,266,1,0],[98977,74,4,1,0],[98978,64,31,1,0],[98979,63,11,1,0],[98981,63,7,4,0],[98982,56,72,1,0],[98983,62,56,1,0],[98984,56,94,1,0],[98985,60,270,4,0],[98986,61,280,4,0],[105406,192,53,6,0],[105411,189,18,3,0]]}})

*/

	
	// cb �� caller �먯꽌 吏곸젒 泥섎━.

	getFavs: function( param ) {
		// queyr �좎룞�� 
		console.log( 'h mgr : fet favs' );
		var param = {  cb : param.cb};
		em.ahelper.getFavs(param);

	},


/*

	// 占쎌쥙猷욑옙�용쐻占썩뫗�깍옙占퐏tatus 占쎌쥙猷욑옙占�占쎌쥙猷욑옙�용쐻占쎌늿��占쎌쥙�ι뇡�뱀굲 占쎌쥙猷욑옙�용쐻占쎌늿�� 
	print_status : function (obj) {
		$("#status_box").empty();
		$("#status_box").append( this.print_obj(obj) );
	},

	print_obj:function(o){ 
		var str=''; 
		var p;
		for(p in o){ 
			if(typeof o[p] != 'Object'){ 
				str+= p + ': ' + o[p]+'; </br>'; 
			}
			else
			{ 
				str+= p + ': { ' + this.print_obj(o[p]) + '} <br/>'; 
			}
		}
		return str; 
//$('body').append( print(myObject) );
	},

	dumpobj: function(ct , arr , level) {
		var dumped_text = "";
		if(!level) level = 0;

			//The padding given at the beginning of the line.
			var level_padding = "";
			for(var j=0; j < level+1; j++) level_padding += "? ";

				if(typeof(arr) == 'object') { //Array/Hashes/Objects
					for(var item in arr) {
					var value = arr[item];

					if(typeof(value) == 'object') { //If it is an array,
					dumped_text += level_padding + "'" + item + "' ...\n";
					dumped_text += this.dumpobj(ct, value,level+1);
				} else {
				dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
				}
			}
		} else { //Stings/Chars/Numbers etc.
			dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
		}
		ct.empty();
		ct.append($("<p>").append(dumped_text));
		return dumped_text;
	},
*/

// 占쏙옙占쎄쑬�믭옙占�..  占썩뫁��占쎈벡��占쎄쑬��. 占쎄쑴�� .
initialize: function() {
		debug_log( " hnt init " );

	var outer = this;
		// define actions   : outer 占싼딆뒠..  fucntio 占쎈챷��揶쏆빘猿쒎첎占퐐his  占쎈떯��  hntMgr 占쏙옙outer 嚥∽옙.. 
		this.action_stage = [
		{cmd: "test" , 	doaction: outer.doTest },
		{cmd: "test2nd" , 	doaction: this.doTest2nd },
			{cmd: "worldmap" , doaction: outer.doWMap },
			{cmd: "armament_set_ta" , 	doaction: outer.doArmament_set_ta},	
			{cmd: "sol_edu" , 	doaction: outer.doSolEdu},
			{cmd: "conscribe" , doaction: outer.doConscribe},
				//{cmd: "getcitinfo" , doaction: outer.doGetCitInfo },
			{cmd: "armament_at" , 	doaction: outer.doArmament_at},
			{cmd: "armament_at_cost" , doaction: outer.doArmament_att_wcost },		
						//{cmd: "getcitinfo" , doaction: outer.doGetCitInfo },	
			];
		this.cur_action = "";	// empty ... reset 
		this.next_action_idx = 0;
	},
		
			//{cmd: "worldmap" , 	doaction: function () { outer.doWmap.call(outer); } },


};



// Expert Info (Chat/Sequence): 
// GET /game/api_world_map.php?jsonpcallback=jsonp1322034289959\
// &_=1322034437410
// &key=3badb54bda7e38920062ad493d1c9944
// &x=224&y=250
// &_l=en HTTP/1.1\r\n



// 222/ 252 : 3 star 4 
// 224/ 253  :4 start 29


// /soldier_educate_api.php?jsonpcallback=jsonp1321974261717&_=1321974450455
//&key=a0ec2950f34992bd4d5db145cfea95d3
//&city=3070&_l=en&_p=EW-DROID

/*
2: sp
8 : lanu
15 : ov
17: k
jsonp1321974261717(
{"code":0,
"ret":
{"soldiers":
[[1,0,1],[2,121,1],[3,0,1],[4,0,1],[5,0,1],[6,0,1],[7,0,1],[8,1528,1],[9,0,1],[10,12,1],[11,0,1],[12,0,1],[13,0,1],[14,0,1],[15,2077,1],[16,0,1],[17,2699,1],[18,1,1]],
"space":6562,"head":8356,"def":1,"next":[0,0],"f":-38261}})
*/




/*
 armament_action_do_api.php?
 jsonpcallback=jsonp1321974261718&_=1321974460167&key=a0ec2950f34992bd4d5db145cfea95d3
 &city=3070
 &action=do_war
 &attack_type=3
 &tai_num=3
 &area=184&area_x=53
 &_l=en
 &_p=EW-DROID


jsonp1321974261718(
{"code":0,
"ret":
{"carry":180,"cost_food":180,"cost_wood":0,"cost_iron":0,"cost_gold":0,"distance":2040,"travel_sec":0}})
*/



/*

get_cityinfo_api.php?
jsonpcallback=jsonp1321974267349&_=1321974460196&key=a0ec2950f34992bd4d5db145cfea95d3
&city=3070
&_l=en
&_p=EW-DROID


2 : remain area
192 : area
484741,21213527,2915768,21213527,220137,21213527,1075887,21213527,  : resource  cur / max
9652,9644, : popul
5,5,5,29, :  farm
18,26,24,22,13,24,18,  : structure   town, bar, wall, arena, storage,  research, fucility

jsonp1321974267349(
{"code":0,
"ret":
{"city":
[2,193,
	484741,21213527,2915768,21213527,220137,21213527,1075887,21213527, //9
	9652,9644, 	//11
	5,5,5,29,		//15
	18,26,24,22,13,24,18,   // 22
	[{"id":39545,"itemid":166,"secs":118075}, //23
		{"id":40536,"itemid":166,"secs":462108},
		{"id":40819,"itemid":120,"secs":45057}]
	,0],
	"grade":62,"money":0}
}
)
*/


/*
 // 
 armament_action_task_api.php?
 jsonpcallback=jsonp1321974261719&_=1321974468658&key=a0ec2950f34992bd4d5db145cfea95d3
 &city=3070
	 &action=war_task
 &attack_type=3&tai_num=3
 	&area=184&area_x=53
 &_l=en
 &_p=EW-DROID
 &carry=180&cost_food=180&cost_wood=0&cost_iron=0&cost_gold=0&distance=2040&travel_sec=0


jsonp1321974261719(
{"code":0,
"ret":
	{"cd":
	[{"id":3281779,"cdtype":4,"target":3,"owner":0,"secs":0,"ret":0,"ext":"184\/53"}]
	}
}
)

*/



/*
get_cdinfo_api.php?
jsonpcallback=jsonp1321974261720&_=1321974470536&key=a0ec2950f34992bd4d5db145cfea95d3
&city=3070
&_l=en
&_p=EW-DROID


jsonp1321974261720(
{"code":0,
"ret":
	{"cdlist":
		[
			{"id":757395,"cdtype":1,"target":4,"owner":0,"secs":170134},
			{"id":780811,"cdtype":1,"target":9,"owner":0,"secs":504194},
			{"id":805491,"cdtype":0,"target":5,"owner":0,"secs":5220},
			{"id":206987,"cdtype":2,"target":5,"owner":26106,"secs":58628}],
			"grade":62,"money":0}}
)
*/


/*
message_api.php?
jsonpcallback=jsonp1321974261721&_=1321974484078&key=a0ec2950f34992bd4d5db145cfea95d3
&page=1
&_l=en
&_p=EW-DROID


jsonp1321974261721(
{"code":0,
"ret":
	{"mail":
		[
			{"id":"473273","sender":"sys","title":"\u2605\u2605 \uacc4\uc88c\uc774\uccb4 \uc82c \uad6c\ub9e4 \ubc29\ubc95 \/ \uc9c0\uae09 \uc2dc\uac04 \u2605\u2605","time":1321968210,"new":1},{"id":"471036","sender":"sys","title":"\u2605\u2605 \uacc4\uc88c\uc774\uccb4 \uc82c \uad6c\ub9e4 \ubc29\ubc95 \/ \uc9c0\uae09\uc2dc\uac04 \u2605\u2605","time":1321925649,"new":1},
			{"id":"470279","sender":"sys","title":"Famine happens in Castle [185\/53]!","time":1321913471,"new":0},{"id":"469881","sender":"sys","title":"NO Food in Castle [185\/53]!","time":1321889675,"new":1},{"id":"469772","sender":"sys","title":"Eliminated by [Led] adam in PVP","time":1321886003,"new":1},{"id":"468104","sender":"sys","title":"\u2605\u2605 \uacc4\uc88c\uc774\uccb4 \uc82c \uad6c\ub9e4 \ubc29\ubc95 \/ \uc9c0\uae09 \uc2dc\uac04 \u2605\u2605","time":1321842417,"new":1},
			{"id":"468103","sender":"\uae40\uc120\uc9c4","title":"24\uc77c \ubaa9\uc694\uc77c 18\uc2dc \ud734\uc804\ud574\uc81c","time":1321838344,"new":0},{"id":"467545","sender":"sys","title":"[185\/53]\uc131 \ub0b4\uc5d0 \uc2dd\ub7c9\uc774 \uc5c6\uc2b5\ub2c8\ub2e4!","time":1321829813,"new":1},{"id":"466090","sender":"sys","title":"Resource Colony 4\/72 is expired","time":1321791198,"new":1},{"id":"467552","sender":"\ud751\uc778","title":"\ud751\uc778\ub18d\uc7a5 \uc0ac\uc6a9\ubc29\ubc95","time":1321762518,"new":0},
			{"id":"467551","sender":"\ud751\uc778","title":"\ud751\uc778\ub18d\uc7a5 \uc0ac\uc6a9\ubc29\ubc95","time":1321762510,"new":0},{"id":"467550","sender":"\uae40\uc120\uc9c4","title":"\uc0ac\uce6d\uc8fc\uc758","time":1321762288,"new":0},{"id":"467549","sender":"\ud751\uc778","title":"\uc8fc \ud751\uc778\ub18d\uc7a5\uac1c\uc5c5 \uc0ac\uc6a9\ubc29\ubc95","time":1321762278,"new":0},{"id":"467548","sender":"\ud751\uc778","title":"(\uc8fc) \ud751\uc778\ub18d\uc7a5 \uac1c\uc5c5","time":1321762183,"new":0},{"id":"467547","sender":"\ud751\uc778","title":"\ub2e4\ub4e4 \uc218\uc1a1\ud301 \ub2e4\uc2dc-\ucd5c\uc885\uc801","time":1321759625,"new":0},{"id":"467546","sender":"sys","title":"\u2605\u2605 \uacc4\uc88c\uc774\uccb4 \uc82c \uad6c\ub9e4 \ubc29\ubc95 \/ \uc9c0\uae09 \uc2dc\uac04 \u2605\u2605","time":1321755594,"new":1},{"id":"462487","sender":"sys","title":"\u2605\u2605 \uacc4\uc88c\uc774\uccb4 \uc82c \uad6c\ub9e4 \ubc29\ubc95 \/ \uc9c0\uae09 \uc2dc\uac04 \u2605\u2605","time":1321680488,"new":1},{"id":"462486","sender":"sys","title":"\u2605\u2605 \uacc4\uc88c\uc774\uccb4 \uc82c \uad6c\ub9e4 \ubc29\ubc95 \/ \uc9c0\uae09 \uc2dc\uac04 \u2605\u2605","time":1321677413,"new":1},{"id":"462485","sender":"sys","title":"\u2605\u2605 \uacc4\uc88c\uc774\uccb4 \uc82c \uad6c\ub9e4 \ubc29\ubc95 \/ \uc9c0\uae09 \uc2dc\uac04 \u2605\u2605","time":1321675795,"new":1},
			{"id":"462484","sender":"sys","title":"\u2605\u2605 \uacc4\uc88c\uc774\uccb4 \uc82c \uad6c\ub9e4 \ubc29\ubc95 \/ \uc9c0\uae09 \uc2dc\uac04 \u2605\u2605","time":1321675492,"new":1}
			],
			"max":2}})
*/


/*

/war_result_list_api.php?
jsonpcallback=jsonp1321974261722&_=1321974489374&key=a0ec2950f34992bd4d5db145cfea95d3
&page=1
&type=3
&_l=en
&_p=EW-DROID


jsonp1321974261722(
{"code":0,
	"ret":
		{"war":
			[
			{"id":3276196, // id !! 
				"type":3,"aid":3074,"did":0,"aname":"james!!","dname":null,
				"acid":3070,"dcid":0,
					"acity":"\ucc9c\uc0c1\uc131",
					"dcity":"\ucc9c\uc0c1\uc131",
					"ax":185,"ay":53,
					
					"dx":184,"dy":53, // coodi 

					"flag":1,
					"time":1321974150,
					"new":1}
			],"max":1}})
*/


/*

war_result_info_api.php?
jsonpcallback=jsonp1321974261723&_=1321974497945&key=a0ec2950f34992bd4d5db145cfea95d3
&id=3276196		// id
&_l=en
&_p=EW-DROID



// Horror(694)
jsonp1321974261723({
"code":0,
"ret":
	{
		"war_report":null,
		"scout_report":
			{"flag":0,
			"result":
			"<b>[Hero]<\/b><br\/>ChaosSlave (Lvl.3)<br\/><br\/><b>[Troops]<\/b><br\/>Horror(694)<br>Attack(15)&nbsp;&nbsp;Defense(8)&nbsp;&nbsp;Health(80)<br><br>"},
			"other_report":null}})
*/


/*
api_fav.php?
jsonpcallback=jsonp1321974261724&_=1321974513522&key=a0ec2950f34992bd4d5db145cfea95d3
&act=addreport
&wid=3276196&cat=2
&_l=en&_p=EW-DROID

jsonp1321974261757(
{"code":0,"ret":""}
)
*/





// james song
/*

/game/api_world_map.php?jsonpcallback=jsonp1322055723835&_=1322055832019&key=3badb54bda7e38920062ad493d1c9944&x=203&y=250&_l=en HTTP/1.1
curl "k2.emrosswar.com/game/api_world_map.php?jsonpcallback=jsonp1322055723835&_=1322055832019&key=3badb54bda7e38920062ad493d1c9944&x=203&y=250&_l=en" -A "Mozilla/5.0 (Linux; U; Android 2.2; en-us; sdk Build/FRF91) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"


/game/armament_action_do_api.php?jsonpcallback=jsonp1322055723836&_=1322055842519&key=3badb54bda7e38920062ad493d1c9944&city=14281&act=anum&x=204&y=251&_l=en HTTP/1.1
 curl "k2.emrosswar.com/game/armament_action_do_api.php?jsonpcallback=jsonp1322055723836&_=1322055842519&key=3badb54bda7e38920062ad493d1c9944&city=14281&act=anum&x=204&y=251&_l=en" -A "Mozilla/5.0 (Linux; U; Android 2.2; en-us; sdk Build/FRF91) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"


GET /game/soldier_educate_api.php?jsonpcallback=jsonp1322055723837&_=1322055842552&key=3badb54bda7e38920062ad493d1c9944&city=14281&_l=en HTTP/1.1
 curl "k2.emrosswar.com/game/soldier_educate_api.php?jsonpcallback=jsonp1322055723837&_=1322055842552&key=3badb54bda7e38920062ad493d1c9944&city=14281&_l=en" -A "Mozilla/5.0 (Linux; U; Android 2.2; en-us; sdk Build/FRF91) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"


 GET /game/get_cityinfo_api.php?jsonpcallback=jsonp1322055727502&_=1322055852675&key=3badb54bda7e38920062ad493d1c9944&city=14281&_l=en HTTP/1.1
 curl "k2.emrosswar.com/game/get_cityinfo_api.php?jsonpcallback=jsonp1322055727502&_=1322055852675&key=3badb54bda7e38920062ad493d1c9944&city=14281&_l=en" -A "Mozilla/5.0 (Linux; U; Android 2.2; en-us; sdk Build/FRF91) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"


GET /game/gen_conscribe_api.php?jsonpcallback=jsonp1322055723838&_=1322055873776&key=3badb54bda7e38920062ad493d1c9944&city=14281&action=gen_list&extra=1&_l=en HTTP/1.1
 curl "k2.emrosswar.com/game/gen_conscribe_api.php?jsonpcallback=jsonp1322055723838&_=1322055873776&key=3badb54bda7e38920062ad493d1c9944&city=14281&action=gen_list&extra=1&_l=en" -A "Mozilla/5.0 (Linux; U; Android 2.2; en-us; sdk Build/FRF91) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"

jsonp1322055723838({"code":0,"ret":{"hero":[
{"id":9176,"gid":210,"p":44,"i":8,"c1":17,"f":34,"g":12,"c2":613,"fy":0,"s":0,"e":10,"w":0,"tw":30,"tl":79,
	"ex":59758,"te":257100,"np":0,"ni":0,"nc1":0,"nc2":0,"ns":0,"ncd":0,"pr":36000},
{"id":20635,"gid":185,"p":10,"i":40,"c1":13,"f":50,"g":11,"c2":559,"fy":0,"s":0,"e":10,"w":0,"tw":0,"tl":89,"ex":106717,"te":116863,"np":0,"ni":0,"nc1":0,"nc2":0,"ns":0,"ncd":0,"pr":33000},{"id":24349,"gid":142,"p":18,"i":26,"c1":18,"f":38,"g":4,"c2":354,"fy":0,"s":0,"e":10,"w":1,"tw":12,"tl":7,"ex":398,"te":468,"np":0,"ni":0,"nc1":0,"nc2":0,"ns":0,"ncd":0,"pr":12000},{"id":81059,"gid":200,"p":22,"i":10,"c1":15,"f":50,"g":3,"c2":299,"fy":0,"s":0,"e":10,"w":0,"tw":0,"tl":1,"ex":0,"te":212,"np":0,"ni":0,"nc1":0,"nc2":0,"ns":0,"ncd":0,"pr":9000}]}})


GET /game/armament_action_do_api.php?jsonpcallback=jsonp1322055723839&_=1322055884101&key=3badb54bda7e38920062ad493d1c9944&city=14281&action=do_war&attack_type=7&gen=185&area=204&area_x=251&soldier_num2=33&_l=en HTTP/1.1
 curl "k2.emrosswar.com/game/armament_action_do_api.php?jsonpcallback=jsonp1322055723839&_=1322055884101&key=3badb54bda7e38920062ad493d1c9944&city=14281&action=do_war&attack_type=7&gen=185&area=204&area_x=251&soldier_num2=33&_l=en" -A "Mozilla/5.0 (Linux; U; Android 2.2; en-us; sdk Build/FRF91) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"

GET /game/armament_action_task_api.php?jsonpcallback=jsonp1322055723840&_=1322055886719&key=3badb54bda7e38920062ad493d1c9944&city=14281&action=war_task&attack_type=7&gen=185&area=204&area_x=251&soldier_num2=33&_l=en&carry=1980&cost_food=1980&cost_wood=0&cost_iron=0&cost_gold=0&distance=2160&travel_sec=300 HTTP/1.1
 curl "k2.emrosswar.com/game/armament_action_task_api.php?jsonpcallback=jsonp1322055723840&_=1322055886719&key=3badb54bda7e38920062ad493d1c9944&city=14281&action=war_task&attack_type=7&gen=185&area=204&area_x=251&soldier_num2=33&_l=en&carry=1980&cost_food=1980&cost_wood=0&cost_iron=0&cost_gold=0&distance=2160&travel_sec=300" -A "Mozilla/5.0 (Linux; U; Android 2.2; en-us; sdk Build/FRF91) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"
*/